package map;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo3 {
    public static void main(String[] args) {
        String line="i love java! thinking in java! hello world!";
        Map<Character,Integer> map=new HashMap<>();
        for(int i=0;i<line.length();i++){
            char c=line.charAt(i);
            if(map.containsKey(c))
                map.put(c,map.get(c)+1);
            else
                map.put(c,1);
        }
//        Set<Map.Entry<Character,Integer>> entrySet=map.entrySet();
//        for(Map.Entry<Character,Integer> o:entrySet)
//            System.out.println(o.getKey()+":"+o.getValue());
        map.forEach((k,v)-> System.out.println(k+":"+v));
    }
}
